﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PCR.Base;
using PCR.Logic;

namespace PCR
{
    public partial class FormAddEditSample : DevComponents.DotNetBar.Office2007Form
    {
        public IStdCurve _stdCurve = null;
        public FormAddEditSample(IStdCurve stdCurve)
        {
            InitializeComponent();

            _stdCurve = stdCurve;
            this.AcceptButton = this.btnOK;
            this.CancelButton = this.btnCancel;
        }

        private void FormEditSample_Load(object sender, EventArgs e)
        {
            if (this._stdCurve == null) // Add mode
            {
                this.Text = "添加样本";
            }
            else // Edit mode
            {
                this.Text = "编辑样本";
                this.textName.Text = this._stdCurve.Name;
                this.textDescription.Text = this._stdCurve.Description;
            }
        }        

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this._stdCurve == null)
                this._stdCurve = PCRRoot.Instance.CreateObject(ObjectType.StdCurve) as IStdCurve;

            this._stdCurve.Name = this.textName.Text;
            this._stdCurve.Description = this.textDescription.Text;

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }
    }
}
